import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class RedFrame extends javax.swing.JFrame implements ActionListener
{

    private fileExitCommand Exit;
    private javax.swing.JMenuBar Meniu;
    private fileOpenCommand Open;
    private btnRedCommand RED;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JPanel jPanel1;
	
	
    public RedFrame() 
    {
        initComponents();
    }

    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        Meniu = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        RED = new btnRedCommand(jPanel1,Color.red);
        Open = new fileOpenCommand(jPanel1);
        Exit = new fileExitCommand(jPanel1);


        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 460, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 401, Short.MAX_VALUE)
        );

        jMenu1.setText("Meniu");

        RED.setText("RED");
        jMenu1.add(RED);

        Open.setText("Open");
        jMenu1.add(Open);

        Exit.setText("Exit");
        jMenu1.add(Exit);

        Meniu.add(jMenu1);

        setJMenuBar(Meniu);

        //aceste trei linii adauga Listenerul definit cu ajutorul actionPerformed pt fiecare buton in parte
        RED.addActionListener((ActionListener) this);
        Open.addActionListener(this);
        Exit.addActionListener(this);       

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
        );

        pack();
    }
    
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RedFrame().setVisible(true);
            }
        });
    }

    public void actionPerformed ( ActionEvent press )
    {
    
        if(press.getSource()==RED)
        {
            RED.execute();
        }
        else
            if(press.getSource()==Open)
            {
               Open.execute();
            }
            else
                if(press.getSource()==Exit)
                {
                    Exit.execute();
                }
    }

}
